home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD Exchange
/
CD Exchange - Volume 1.iso
/
graphics
/
utils
/
videotracker
/
develop
/
source
/
crunch.s
< prev
next >
Wrap
Text File
|
1980-01-02
|
7KB
|
422 lines
opt a+
opt o+
opt ow-
section 1,code_c
move.l #raw,a0
move.l #cru,a1
move.l #raw.e-raw,d0
bsr crunch
move.l d0,d1
move.l #cru,d0
add.l d0,d1
illegal
; ;crunch routine
; ;
; ;a0 = pointer to uncrunched data
; ;a1 = pointer to crunched data
; ;d0 = length uncrunched data
; ;
; ;d0 returns crunched data length
;
offset = $800
crunch
Scrunch:
movem.l d1-d7/a0-a6,-(sp)
move.l a1,a2
move.l a0,a1
add.l d0,a1
movem.l a0-a2,-(sp)
move.l #'PVC!',(a2)+ ;set ascii info
move.l d0,(a2)+ ;raw length
add.l #4,a2 ;crunch length
; lea start,a0
; lea stop,a1
; lea write,a2
moveq #1,d2
clr.w d1
clr.l d7
noteocrunch:
bsr.S blkcrunch
tst.b d0
beq.S crunched
addq.w #1,d1
cmpi.w #264,d1
bne.S nojmp
bsr.w dojmp
nojmp:
crunched:
move.w a2,($dff180).l
cmp.l a0,a1
bgt.S noteocrunch
bsr.w dojmp
bsr.w write1lwd
move.l d7,(a2)+
movem.l (sp)+,a0-a1/a5
; lea start,a0
; lea stop,a1
move.l a1,d2
sub.l a0,d2
move.l d2,(a2)+ ;raw length
clr.l d0
clr.l d1
clr.l d2
clr.l d3
clr.l d4
clr.l d5
lea cnt,a3
movem.w (a3)+,d0-d5
move.l a2,a3
sub.l a0,a3 ;
sub.l a5,a2
move.l a2,d0 ;crunched data length
move.l d0,8(a5)
movem.l (sp)+,d1-d7/a0-a6
rts
blkcrunch:
move.l a0,a3
add.l #offset,a3
cmp.l a1,a3
ble.S nottop
move.l a1,a3
nottop:
moveq #$1,d5
move.l a0,a5
addq #$1,a5
contcrunch:
move.b (a0),d3
move.b $1(a0),d4
quickfind:
cmp.b (a5)+,d3
bne.S contfind
cmp.b (a5),d4
beq.S lenfind
contfind:
cmp.l a5,a3
bgt.S quickfind
bra.S endquickfind
lenfind:
subq #1,a5
move.l a0,a4
scan:
move.b (a4)+,d3
cmp.b (a5)+,d3
bne.S endequ
cmp.l a5,a3
bgt.S scan
endequ:
move.l a4,d3
sub.l a0,d3
subq.l #1,d3
cmp.l d3,d5
bge.S nocrunch
move.l a5,d4
sub.l a0,d4
sub.l d3,d4
subq #1,d4
cmp.l #$4,d3
ble.S small
moveq #$6,d6
cmp.l #$00000101,d3
blt.S oksafe
move.w #$100,d3
oksafe:
bra.S cont1
small:
move.w d3,d6
subq.w #$2,d6
lsl.w #1,d6
cont1:
lea table,a6
cmp.w (a6,d6.w),d4
bge.S nocrunch
move.l d3,d5
move.l d4,maxsoffset
move.b d6,tbloffset
nocrunch:
cmp.l a5,a3
bgt.S contcrunch
endquickfind:
cmp.l #$1,d5
beq.S nothingfound
bsr.S dojmp
move.b tbloffset,d6
move.l maxsoffset,d3
move.w 8(a6,d6.w),d0
bsr.S wd0bits
move.w 16(a6,d6.w),d0
beq.S nolength
move.l d5,d3
subq #1,d3
bsr.S wd0bits
nolength:
move.w 24(a6,d6.w),d0
move.w 32(a6,d6.w),d3
bsr.S wd0bits
addi.w #$1,40(a6,d6.w)
addi.w #$1,$dff188
add.l d5,a0
clr.b d0
rts
nothingfound:
move.b (a0)+,d3
moveq #$8,d0
bsr.S wd0bits
moveq #$1,d0
rts
dojmp:
tst.w d1
beq.S skipjmp
move.w d1,d3
clr.w d1
cmp.w #9,d3
bge.S bigjmp
addq.w #1,cntjmp
subq.w #1,d3
moveq #5,d0
bra.S wd0bits
skipjmp:
rts
bigjmp:
addq.w #1,cntjmp+2
subi.w #9,d3
or.w #%0000011100000000,d3
moveq #11,d0
bra.w wd0bits
wd0bits:
addi.w #$1,$dff188
subq.w #1,d0
copybits:
lsr.l #1,d3
roxl.l #1,d2
bcs.S writelwd
dbf d0,copybits
rts
write1lwd:
clr.w d0
writelwd:
move.l d2,(a2)+
eor.l d2,d7
moveq #1,d2
dbf d0,copybits
rts
;decrunch routine
;
;a0 = pointer to crunched data
;a1 = pointer to uncrunched data
Decrunch:
movem.l d0-d7/a0-a6,-(sp)
add.l 8(a0),a0 ;eind file
; lea d_stop,a0 ; eind van data, kan relatief
; lea $60000,a1 ; destination
move.l -(a0),a2
add.l a1,a2
move.l -(a0),d5
move.l -(a0),d0
eor.l d0,d5
Decrunch_a: lsr.l #1,d0
bne.s Decrunch_b
bsr Decrunch_m
Decrunch_b: bcs.s Decrunch_i
moveq #8,d1
moveq #1,d3
lsr.l #1,d0
bne.s Decrunch_c
bsr Decrunch_m
Decrunch_c: bcs.s Decrunch_k
moveq #3,d1
clr.w d4
Decrunch_d: bsr Decrunch_n
move.w d2,d3
add.w d4,d3
Decrunch_e: moveq #7,d1
Decrunch_f: lsr.l #1,d0
bne.s Decrunch_g
bsr Decrunch_m
Decrunch_g: roxl.l #1,d2
dbra d1,Decrunch_f
move.b d2,-(a2)
dbra d3,Decrunch_e
bra Jump_a
Decrunch_h: moveq #8,d1
moveq #8,d4
bra Decrunch_d
Decrunch_i: moveq #2,d1
bsr Decrunch_n
cmp.b #2,d2
blt.s Decrunch_j
cmp.b #3,d2
beq.s Decrunch_h
moveq #8,d1
bsr Decrunch_n
move.w d2,d3
move.w #12,d1
bra Decrunch_k
Decrunch_j: move.w #9,d1
add.w d2,d1
addq.w #2,d2
move.w d2,d3
Decrunch_k: bsr Decrunch_n
Decrunch_l: subq.w #1,a2
move.b 0(a2,d2.w),(a2)
dbra d3,Decrunch_l
Jump_a: cmp.l a2,a1
blt Decrunch_a
; tst.l d5
; bne.s Error_a
move.l #0,d0 ;no errors!
movem.l (sp)+,d0-d7/a0-a6
rts
; ;jmp $30000 ; of iets anders
; ;illegal
;Error_a: ;move.w #$FFFF,d0
;Error_b: ;move.w d0,$DFF180
; ;sub.l #1,d0
; ;bne.s Error_b
; move.l #-1,d0 ;error!
; rts
; ;illegal ; laat amiga vastlopen/return
Decrunch_m: move.l -(a0),d0
eor.l d0,d5
move #$10,CCR
roxr.l #1,d0
rts
Decrunch_n: subq.w #1,d1
clr.w d2
Decrunch_o: lsr.l #1,d0
bne.s Decrunch_p
move.l -(a0),d0
eor.l d0,d5
move #$10,CCR
roxr.l #1,d0
Decrunch_p: roxl.l #1,d2
dbra d1,Decrunch_o
rts
table:
offst: dc.w $0100,$0200,$0400,$1000
blklnoff: dc.w $0008,$0009,$000a,$000c
blklength: dc.w $0000,$0000,$0000,$0008
blkcdlen: dc.w $0002,$0003,$0003,$0003
blkcode: dc.w $0001,$0004,$0005,$0006
cnt: dc.w $0,$0,$0,$0
cntjmp: dc.w $0,$0
maxsoffset: dc.l 0
tbloffset: dc.l 0
incdir 'w:'
;raw equ $80000
;raw.e equ raw+366948
raw
; incbin 'routine/ColorGrid.rot'
; incbin 'routine/CopperMagnify4.rot'
incbin 'routine/CopperMagnify8.rot'
; incbin 'routine/CopperPalette_16.rot'
; incbin 'routine/Landscape_L2.rot'
; incbin 'routine/Landscape_L4.rot'
; incbin 'routine/Landscape_L8.rot'
; incbin 'routine/Landscape_L16.rot'
; incbin 'routine/Landscape_L32.rot'
; incbin 'routine/Object_H2.rot'
; incbin 'routine/Object_H4.rot'
; incbin 'routine/Object_H8.rot'
; incbin 'routine/Object_L2.rot'
; incbin 'routine/Object_L4.rot'
; incbin 'routine/Object_L8.rot'
; incbin 'routine/Object_L16.rot'
; incbin 'routine/Object_L32.rot'
; incbin 'routine/Object_L64.rot'
; incbin 'routine/PictureMove.rot'
; incbin 'routine/Plasma.rot'
; incbin 'routine/ScrollBig_L8.rot'
; incbin 'routine/ScrollBigNTSC_L8.rot'
; incbin 'routine/ScrollNTSC_H4.rot' ;raw !
; incbin 'routine/ScrollNTSC_L2.rot'
; incbin 'routine/ScrollNTSC_L16.rot'
; incbin 'routine/ScrollNTSC_L32.rot'
; incbin 'routine/Scroll_H2.rot'
; incbin 'routine/Scroll_H4.rot' ;raw !
; incbin 'routine/Scroll_L2.rot'
; incbin 'routine/Scroll_L4.rot'
; incbin 'routine/Scroll_L8.rot'
; incbin 'routine/Scroll_L16.rot'
; incbin 'routine/Scroll_L32.rot'
; incbin 'routine/Stars.rot'
; incbin 'routine/Vector_L2.rot'
; incbin 'routine/Vector_L4.rot'
; incbin 'routine/Vector_L8.rot'
; incbin 'routine/Vector_L16.rot'
; incbin 'routine/Vector_L32.rot'
; incbin 'routine/Vector_H2.rot'
; incbin 'routine/Vector_H4.rot'
; incbin 'routine/VectorShade_L2.rot'
; incbin 'routine/Wave.rot'
raw.e
cnop 0,2
cru ds.b 10000